#include"TCP_SOCKET.hpp"
#include<cassert>

int main(int argc,char* argv[])
{
    if(argc!=3)
    {
        cout<<"Run program error!!!"<<endl;
        return -1;
    }
    string ip=argv[1];
    uint16_t port=stoi(argv[2]);

    //客户端创建流程
    TcpSocket cli_sock;
    //1.创建套接字
    assert(cli_sock.Socket());
    //2.向服务端发送链接请求
    assert(cli_sock.Connect(ip,port));
    //3.循环发送数据
    while(1)
    {
        string buf;
        cout<<"client say:";
        fflush(stdout);
        cin>>buf;
        assert(cli_sock.Send(buf));

        buf.clear();
        assert(cli_sock.Recv(&buf));
        cout<<"server say"<<buf<<endl;
    }
    //4.关闭套接字
    cli_sock.Close();
    return 0;
}